<?php


namespace Modules\Admin\Http\Controllers\Authorization\Role;


use Illuminate\Support\Facades\DB;
use Modules\Common\General\Security\Authorization\Manager;
use Modules\Common\Models\AdminRole;
use Modules\Common\Util\Api;

class Create
{
    /**
     * @Route(path=/api/admin/authorization/role method=post)
     */
    public function index()
    {
        DB::transaction(function () {
            $role = AdminRole::safeCreateWithRequestParams(['name'], ['sort' => 0]);
            $m = new Manager();
            $m->addRole($role->id);
        });
        return Api::success();
    }

}
